package com.xiaoy.core.base.security.user.entity;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.xiaoy.core.base.security.role.entity.Role;
import com.xiaoy.entity.BaseBean;
import com.xiaoy.util.store.config.ConfigTable;
@Entity
@Table(name=ConfigTable.Base.USER_ROLE_TABLENAME)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class UserRole extends BaseBean{

//	private long userId;
//	private long roleId;
	
	private User user;
	private Role role;
	
	public UserRole (){}
	public UserRole (long id){
		role = new Role(id);
	}
	
	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) 
	@JoinColumn(name="userId")
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	
	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) 
	@JoinColumn(name="roleId")
	public Role getRole() {
		return role;
	}
	public void setRole(Role role) {
		this.role = role;
	}
	
}
